<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="./vue.js"></script>
    
</head>
<body>
    <div id="app">
        {{message}}
        <button @click="plus">{{a}}</button>
        反转之后的消息：<p>{{reverseMessage}}</p>
        <p>{{ fullName }}</p>
        <div v-for="item in students">
            {{item.id}}   {{item.name}}
        </div>
        <button-counter></button-counter>
        <button-counter></button-counter>
        <input type="text" v-model="input">
    </div>
</body>
<script>
    // 创建组件
    Vue.component('button-counter', {
        data: function() {
            return {
                count: 0
            }
        },
        template: '<button v-on:click="count++">You clicked me {{ count }} times.</button>'
    })
    //vue实例化
    var app=new Vue({
        
        el:"#app",
        data:{
            message:'hello Vue',
            a:1,
            students:[{
                id:1,
                name:'lisi'
            },{
                id:2,
                name:"zhangsan"
            }],
            input:""
        },
        methods:{
            plus(){
                this.a++;
            },
        },
        computed:{
            reverseMessage(){
                return this.message.split("").reverse().join("")
            }
        },
        watch: {
            input(newInput,oldInput){
                console.log(newInput,oldInput)
            }
        },
    })
    
</script>
</html>